<template>
  <el-drawer
    :append-to-body="true"
    :wrapperClosable="false"
    title="查看解析"
    size="840px"
    :visible="open"
    @close="handleClose"
  >
    <div class="drawer_container">
      <div class="answer_list">
        <div class="answer_question">
          <!--  包含html    -->
          <div v-if="$isIncludesHtml(topicItem.content)" :id="topicItem.id" class="question_content line_feed" v-html="`${topicItem.content.slice(0,3)}<span class='color_orange'>【${$store.getters.topicTypeText[topicItem.topicType]}】</span>${$renderedDescription(topicItem.content.slice(3))}`"></div>
          <!--  不包含html    -->
          <div v-else :id="topicItem.id" class="question_content line_feed" v-html="`<span class='color_orange'>【${$store.getters.topicTypeText[topicItem.topicType]}】</span>${$renderedDescription(topicItem.content)}`"></div>
          <!--  试题详情  -->
          <div class="item_answer">
            <!--    单选题部分    topicItem.userAnswer    -->
            <template v-if="topicItem.topicType == 0">
              <div class="option_item pointer" v-for="(answerItem, answerIndex) in topicItem.ccTopicOptionList" :key="answerIndex">
                <div class="option_label">{{labelList[answerIndex]}}</div>
                <div class="option_value line_feed" v-html="$renderedDescription(answerItem.optionValue)"></div>
              </div>
            </template>
            <!--    多选题部分   multiAnswers     -->
            <template v-if="topicItem.topicType == 1">
              <div class="option_item pointer"  v-for="(answerItem, answerIndex) in topicItem.ccTopicOptionList" :key="answerIndex">
                <div class="option_label">{{labelList[answerIndex]}}</div>
                <div class="option_value line_feed" v-html="$renderedDescription(answerItem.optionValue)"></div>
              </div>
            </template>
            <!--    判断题部分        -->
            <el-radio-group
              disabled
              v-removeAriaHidden
              v-if="topicItem.topicType == 2"
              v-model="topicItem.userAnswer"
            >
              <el-radio :label="'正确'">对</el-radio>
              <el-radio :label="'错误'">错</el-radio>
            </el-radio-group>
          </div>
          <div class="detail_box">
            <!--  答案：  -->
            <template v-if="topicItem.answer">
              <div v-if="$isIncludesHtml(topicItem.answer)" class="score_got" v-html="`${topicItem.answer.slice(0,3)}答案：${$renderedDescription(topicItem.answer.slice(3))}`"></div>
              <div v-else class="score_got" v-html="`答案：${$renderedDescription(topicItem.answer)}`"></div>
            </template>
            <!--  解析：  -->
            <template v-if="topicItem.resolve">
              <div v-if="$isIncludesHtml(topicItem.resolve)" class="resolve_text" v-html="`${topicItem.resolve.slice(0,3)}解析：${$renderedDescription(topicItem.resolve.slice(3))}`"></div>
              <div v-else class="resolve_text" v-html="`解析：${$renderedDescription(topicItem.resolve)}`"></div>
            </template>
            <!--  准确率：  -->
            <div class="answer_range">准确率：{{topicItem.answerRange}}%</div>
          </div>
        </div>
      </div>
      <div class="btns">
        <el-button @click="handleClose">关闭</el-button>
      </div>
    </div>
  </el-drawer>
</template>

<script>
export default {
  name: 'AnalysisDrawer',
  props:{
    open:{
      type: Boolean,
      default: false
    },
    topicItem:{
      type: Object,
      default: ()=>{
        return {}
      }
    }
  },
  data(){
    return{
      //选项列表
      labelList: this.$store.getters.EN,
    }
  },
  methods: {
    //关闭抽屉
    handleClose() {
      this.$emit('update:open', false)
    },
  },
}
</script>

<style scoped lang="scss">
.drawer_container{
  height: 100%;
  padding: 17px 31px;
  box-sizing: border-box;
  border-top: 1px solid #EDEFF0;
  .answer_list {
    width: 100%;
    height: calc(100vh - 178px);
    overflow: auto;
    .answer_question {
      .question_content{
        font-family: PingFangSC, PingFang SC, sans-serif;
        font-weight: 400;
        font-size: 16px;
        color: #333333;
      }
      .item_answer {
        width: 100%;
        margin: 22px 0 0;
        .option_item{
          width: 100%;
          display: flex;
          margin-bottom: 22px;
          .option_label{
            width: 24px;
            height: 24px;
            margin-right: 10px;
            background: #FFFFFF;
            border: 1px solid #DDDDDD;
            border-radius: 50%;
            font-family: PingFangSC, PingFang SC, sans-serif;
            font-weight: 400;
            font-size: 14px;
            color: #999999;
            display: flex;
            justify-content: center;
            align-items: center;
          }
          .option_value{
            min-width: 0;
            flex:1;
            font-family: PingFangSC, PingFang SC, sans-serif;
            font-weight: 400;
            font-size: 16px;
            color: rgba(0,0,0,0.85);
          }
        }
      }
      .detail_box{
        margin-top: 10px;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px 0;
        .score_got{
          font-family: PingFangSC, PingFang SC, sans-serif;
          font-weight: 400;
          font-size: 16px;
          color: #28B28B;
        }
        .resolve_text{
          font-family: PingFangSC, PingFang SC, sans-serif;
          font-weight: 400;
          font-size: 16px;
          color: #333333;
        }
        .answer_range{
          font-family: PingFangSC, PingFang SC, sans-serif;
          font-weight: 400;
          font-size: 16px;
          color: #999999;
        }
      }
    }
  }
  .btns{
    margin-top: 20px;
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
}
</style>
<style>
.color_orange {
  color: #ef7d00;
}
</style>
